package com.wenmingliang.demo2;

import java.util.concurrent.TimeUnit;

public class LockSupportDemo {

    public static void main(String[] args) {

        Object object = new Object();

        Thread thread1 = new Thread(() -> {
            synchronized (object) {
                try{
                    object.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "t1");
        thread1.start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {

            e.printStackTrace();
        }

        new Thread(() ->{
            synchronized (object) {
                object.notify();
                System.out.println(Thread.currentThread().getName() + "\t");
            }
        }, "t2").start();
    }
}
